function register(data) {
    axios({
        method: 'post',
        url: '/register',
        data:data  
    }).then(function (response) {
        alert('注册成功')
        location.href='login.html'
        console.log(response);
    }).catch(function (error) {
        console.log(error);
    })
}

const btn = document.getElementById('btn-register')
const form = document.querySelector('.register-form')

btn.onclick = function(e){
    e.preventDefault()
    let data = serialize(form, { hash: true, empty: true })
    let {username,password} = data
    if(!regTest(username,password)){
        pxmu.fail('用户名或密码格式不正确')
        return 
    }  
    register(data)
}

